package com.macro.mall.portal.config;

/**
 * @Author：尚志豪
 * @Package：com.macro.mall.portal.config
 * @Project：mall-swarm-B
 * @name：RedissonConfig
 * @Date：2024/11/4 22:10
 */
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.annotation.Value;

@Configuration
public class RedissonConfig {
    @Value("${spring.redis.host:150.158.86.96}")
    private String redisHost;

    @Value("${spring.redis.port:6379}")
    private int redisPort;

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://" + redisHost + ":" + redisPort);
        return Redisson.create(config);
    }
}

